package com.chencs.common.role.service;

import com.chencs.vo.common.grant.RoleModel;
import com.chencs.webmvc.rest.RestFullTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by fangzehua on 2017/6/11.
 */

@Service
public class RoleService {
    private static final Logger logger = LoggerFactory.getLogger(RoleService.class);
    private String TAG = RoleService.class.getName();

    @Autowired
    RestFullTemplate restTemplate;
    /**标志远程服务url**/
    private static final String URLPATH = "service-common/role/";



    public String addRole(RoleModel model) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "add", String.class,model);
        logger.info("roleService addRole zuulGateWay result {}", ret);
        return ret;
    }

    public String getList() throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "getList", String.class,"");
        logger.info("roleService getList zuulGateWay result {}", ret);
        return ret;
    }

    public String delete(RoleModel model) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "delete", String.class,model);
        logger.info("roleService delete zuulGateWay result {}", ret);
        return ret;
    }

    public String findRoleById(String roleID) throws Exception{
        RoleModel model = new RoleModel();
        model.setRoleID(roleID);
        String ret = restTemplate.postForObject(URLPATH + "get", String.class,model);
        logger.info("roleService findRoleById zuulGateWay result {}", ret);
        return ret;
    }

    public String update(RoleModel model) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "update", String.class,model);
        logger.info("roleService update zuulGateWay result {}", ret);
        return ret;
    }

   }
